<script setup>
import {onMounted, ref} from "vue";
import {showNotify, showSuccessToast, showToast} from "vant";
import {currentUser} from "@/App.vue";
import router from "@/router";

const homeOrder = ref([
  {link:'/homepage',icon:'home-o',title:'主页'},
  {link:'/more',icon:'other-pay',title:'更多'},
  {link:'/more',icon:'add-o'},
  {link:'/order',icon:'orders-o',title:'订单'},
  {link:'/user',icon:'contact-o',title:'我的'},
]
)

const actionSheetShow = ref(false)
const actions = ref([
  {name:'发订单'},
  {name:'发动态'},
])

const sheetSelect = (item) => {
  if (item.name == '发订单'){
    router.push('/launchOrder');
  }else {
    router.push('/launchCard');
  }
}

const addHandle = () => {
  actionSheetShow.value = true
}

// onMounted(() => {
//   if (currentUser.value === null) {
//     showNotify({ type: 'warning', message: '请先登录一下吧' });
//     router.push('/login')
//   }
// })
</script>

<template>
  <keep-alive>
    <router-view></router-view>
  </keep-alive>

  <van-tabbar route>
    <van-tabbar-item replace to="/homepage" icon="home-o">主页</van-tabbar-item>
    <van-tabbar-item replace to="/more" icon="other-pay">动态</van-tabbar-item>
    <van-tabbar-item replace icon="add-o" @click="addHandle"></van-tabbar-item>
    <van-tabbar-item replace to="/order" icon="orders-o">订单</van-tabbar-item>
    <van-tabbar-item replace to="/user" icon="contact-o">我的</van-tabbar-item>
  </van-tabbar>
  <van-action-sheet v-model:show="actionSheetShow" :actions="actions" @select="sheetSelect" close-on-click-action/>
</template>

<style scoped>

</style>